define(['mui','ajax'], function() {
	mui.init({
		swipeBack: true,
		beforeback: function() {
			//释放内存
			document.body.style.backgroundImage = "url('')";
			document.body.innerHTML = '';
			fristpassword = null;
			repassword = null;
			transtime = null;
			token = null;
			user = null;
			ms = null;
			//返回true，继续页面关闭逻辑
			return true;
		}
	});
	var fristpassword = null;
	var repassword = null;
	var transtime = null;
	var token = null;
	var ms = null;
	var user = null;
	mui.plusReady(function() {
		ms = plus.webview.getWebviewById('index-menu.html');
		cms=plus.webview.currentWebview();
		transtime = getNowFormatDate();
		user = plus.storage.getItem('memberdata');
		var userdata = JSON.parse(user);
		token = userdata.token;
		document.getElementById("changepwd").addEventListener('tap', function() {
			fristpassword = document.getElementById("fristpassword").value;
			repassword = document.getElementById("repassword").value;
			var str = CryptoJS.enc.Utf8.parse(fristpassword);
			var fristpassword_base64 = CryptoJS.enc.Base64.stringify(str);

			var restr = CryptoJS.enc.Utf8.parse(repassword);
			var repassword_base64 = CryptoJS.enc.Base64.stringify(restr);

			mui.post(ajax_modPwordURL, {
				token: token,
				transtime: transtime,
				OldPassword: fristpassword_base64,
				PassWord: repassword_base64,
			}, function(data) {
				//    						console.log(data);
				data = JSON.parse(data);
				if(data.result == 1) {
					mui.toast('修改密码成功');
					mui.back();
					mui.fire(ms, 'changepwdLogintout', {

					});
					//console.log('123')
					
				} else {
					mui.toast(data.message);
				}
			}, 'json');
		}, false)
	});
	//密码显示功能
	require(['jquery'],function(){
		mui('.mui-content .mui-switch').each(function() {
		this.addEventListener('toggle', function(event) {
			if(event.detail.isActive) {
				$(this).parent().siblings("input").attr("type", "text");
			} else {
				$(this).parent().siblings("input").attr("type", "password");
			}
		});
	});
	})
	
})